﻿namespace IPMS.BLL
{
    using IPMS.DAL;
    using System;
    using System.Data;
    using System.Data.SqlClient;

    public class ProjectSupervisor
    {
        private string _CreateBy;
        private string _OwnerGroupID;
        private string _ProjectCode;

        public ProjectSupervisor(string projectCode, string createBy, string ownergroupID)
        {
            this._ProjectCode = projectCode;
            this._CreateBy = createBy;
            this._OwnerGroupID = ownergroupID;
        }

        public int CreateResponsiblePerson()
        {
            SqlCommand sqlCmd = new SqlCommand();
            DataAccessLayer DAL = new DataAccessLayer();
            DAL.AddParamToSQLCmd(sqlCmd, "@ReturnValue", SqlDbType.Int, 0, ParameterDirection.ReturnValue, null);
            DAL.AddParamToSQLCmd(sqlCmd, "@ProjectCode", SqlDbType.NVarChar, 0xff, ParameterDirection.Input, this._ProjectCode.ToString());
            DAL.AddParamToSQLCmd(sqlCmd, "@CreateBy", SqlDbType.NVarChar, 0xff, ParameterDirection.Input, this._CreateBy.ToString());
            DAL.AddParamToSQLCmd(sqlCmd, "@OwnerGroupID", SqlDbType.NVarChar, 0xff, ParameterDirection.Input, this._OwnerGroupID.ToString());
            DAL.SetCommandType(sqlCmd, CommandType.StoredProcedure, "CreateRespPersonSp");
            DAL.ExecuteScalarCmd(sqlCmd);
            return Convert.ToInt16(sqlCmd.Parameters["@ReturnValue"].Value);
        }

        public string ProjectCode
        {
            get
            {
                return this._ProjectCode;
            }
        }
    }
}

